#coding:utf-8
import random
import time

def get_md5_32str(str):
    #MD5 32位大写加密
    import hashlib
    import types
    if type(str) is types.StringType:
        md5 = hashlib.md5()
        md5.update(str)
        return md5.hexdigest().upper()    
    else:
        return ""
 
def get_data_sroted(data):
    result=sorted(data.items(), key=lambda item:item[0])
    test=""
    for i in result:
        test = test+ "".join(i)
    return test

    

if __name__ =="__main__":
    content={"storeCode":"","orderCode":"DDPZ1705240001","mailNO":"DDPZ1705240001","remark":"remark"}
    data={
        "busiType":"alog.ordership.status.notify",
        "notifyId":"60r123",
        "notifyTime":"2017-5-25 10:37:22",
        "format":"json",
        "sign_Method":"md5",
        "partnerCode":"alog",
        "secretKey":"123456",
        "ownerCode":"topownerkj",
        "content":str(content),
        
        }
    result =get_data_sroted(data)
    secretKey="123456"
    data["sign"]=get_md5_32str(secretKey+result+secretKey)
    print data

"""
['data_digest: 7eva%2FWU9u9JY%2FXP4UFOi%2FA%3D%3D',
'logistics_interface: %3CItemInfoQueryRequestDown%3E%3Ccheckword%3Echeckword%3C%2Fcheckword%3E%3CserialNumber%3E00001%3C%2FserialNumber%3E%3CwarehouseCompanyCode%3ELCSFPZ%3C%2FwarehouseCompanyCode%3E%3CcompanyCode%3EALOG%3C%2FcompanyCode%3E%3CpageIndex%3E1%3C%2FpageIndex%3E%3CitemCodeList%3E%3CitemCode%3E%3C%2FitemCode%3E%3C%2FitemCodeList%3E%3C%2FItemInfoQueryRequestDown%3E']



data={"name":"lili","age":"23","sex":"1"}
    result=sorted(data.items(), key=lambda item:item[0])
    test=""
    for i in result:
        test = test+ "".join(i)
    print test

"""

    

